package no.sachmuld.methodcombination.examples.reflection.mock;

import no.sachmuld.methodcombination.api.MethodInvocation;
import no.sachmuld.methodcombination.api.reflection.Default;
import no.sachmuld.methodcombination.api.BehaviourChain;

/**
 *
 */
public class PersonDao {

    private BehaviourChain<PersonDaoBehaviour> chain = new BehaviourChain<>();

    public PersonDao() {
        with(new PersonDaoBehaviour() {
            @Override
            public Person findPersonById(int id, MethodInvocation<Person> methodInvocation) {
                // not implemented
                return null;
            }
        });
    }

    public final Person findPersonById(int id) {
        return new Default<Person>().build(PersonDaoBehaviour.class, PersonDao.class, "findPersonById", Integer.TYPE).execute(this, chain, id);
    }

    final protected PersonDao with(PersonDaoBehaviour... behaviours) {
        chain.addAll(behaviours);
        return this;
    }

}
